package com.tedu.demo1;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * Author：毕龙
 * Date: 2024/6/14 9:24
 */
public class TestJdbc1 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        //1.获取驱动Driver
        Class.forName("com.mysql.cj.jdbc.Driver");
        //2.获取链接
        String url = "jdbc:mysql://localhost:3306/jdbc?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Chongqing";
        String username = "root";
        String password = "root";
        Connection connection = DriverManager.getConnection(url,username,password );
        //3.获取Statement语句
        Statement statement = connection.createStatement();
        //sql语句
        String sql = "insert into user(id, username, password, birthday) values (1,'张三','123456','2024-4-14')";
        //4.执行sql语句
        boolean execute = statement.execute(sql);
        //如果为false表示执行的是增删改
        System.out.println(execute);
        //5.资源释放
        statement.close();
        connection.close();

    }
}
